-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the ability of websockets to get errors #2097
Fix the ability of websockets to get errors #2097
Conversation
@RobinCPel would you mind reviewing this websocket PR? |
Are the golangcli-lint check failures something I need to look at? First glance looks like an infra failure to me rather than something relating to the PR? But if I’m mid-interpreting the results happy to make changes. |
I think I fixed the golangci-lint errors on master, so you might just rebase against that and see if it fixes it for this PR. |
Because DispatchOperation creates tempResponseContext, which is passed into Exec, which is then used in _Subscription to generate the next function. Inside the various subscription functions when generating next the context was captured there. Which means later when the returned function from DispatchOperation is called. The responseContext which accumulates the errors is the tempResponseContext which we no longer have access to to read the errors out of it. Instead add a context to next() so that it can be passed through and accumulated the errors as expected. Added a unit test for this as well.
ed672c7
to
0c1149a
Compare
Some important pointers into the code that might help on review here. Picking a random generated file:
Because the captured context accumulates the errors rather than the context which is passed into the function returned from Doesn't see those errors. For reference in the content of subscriptions the caller of DispatchOperation and its returned function is here: |
Thank you for the additional pointers. This looks correct to me and is a very nice improvement. I'm going to merge this, but if @RobinCPel or other WebSocket devs have any review feedback or comments even after it is merged, I'm happy to address those in a follow-up PR. |
I don't know much about the code generation of GqlGen, but everything that I do understand looks fine! 🚀 |
Thanks for looking it over! |
For WebSockets, the flow and contexts involved were such that the errors in marshaling were always dropped rather than sent as part of the response.
This happened because in a new subscription:
next()
in exec captured thetempResponseContext
, none of the errors generated when callingnext()
are ever populated on the context inside the function returned byDispatchOperation
that collects the errors.To solve this I added a context to the
next(
) call so that the response context from the DispatchOperation returned function is passed all the way down and can appropriately accumulate errors as expected.Added a unit test for this as well.
For reference in the content of subscriptions the caller of DispatchOperation and its returned function is here:
https://github.com/99designs/gqlgen/blob/master/graphql/handler/transport/websocket.go#L352
I have: